package datastruct;

/**
 * Hello world!
 */
public class App {
    /**
     * @param k: An integer
     * @param n: An integer
     * @return: An integer denote the count of digit k in 1..n
     */
    public static int digitCounts(int k, int n) {
        int count = 0;
        for (int i = 0; i < n + 1; i++) {
            String nS = String.valueOf(i);
            String kS = String.valueOf(k);
            char[] nChar = nS.toCharArray();
            for (int j = 0; j < nChar.length; j++) {
                if ((kS+"").equals(nChar[j]+"")) {
                    count++;
                }
            }
        }
        return count;
    }

    public static void main(String[] args) {
        System.out.println(digitCounts(1,1));
        System.out.println("Hello World!");
    }
}
